package com.specialized.coupon.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.specialized.common.core.domain.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
//import com.specialized.common.log.annotation.Log;
//import com.specialized.common.log.enums.BusinessType;
import com.specialized.common.security.annotation.RequiresPermissions;
import com.specialized.coupon.domain.CouponSession;
import com.specialized.coupon.service.ICouponSessionService;
import com.specialized.common.core.web.controller.BaseController;
import com.specialized.common.core.utils.poi.ExcelUtil;

/**
 * 优惠卷场次关系Controller
 *
 * @author djh
 * @date 2024-07-30
 */
@RestController
@RequestMapping("/CouponSession")
public class CouponSessionController extends BaseController {
    @Autowired
    private ICouponSessionService couponSessionService;

/**
 * 查询优惠卷场次关系列表
 */
//@RequiresPermissions("coupon:CouponSession:list")
@GetMapping("/list")
    public Result<CouponSession> list(CouponSession couponSession) {
        startPage();
        List<CouponSession> list = couponSessionService.selectCouponSessionList(couponSession);
        return getDataTable(list);
    }

    /**
     * 导出优惠卷场次关系列表
     */
//    @RequiresPermissions("coupon:CouponSession:export")
//    @Log(title = "优惠卷场次关系", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CouponSession couponSession) {
        List<CouponSession> list = couponSessionService.selectCouponSessionList(couponSession);
        ExcelUtil<CouponSession> util = new ExcelUtil<CouponSession>(CouponSession. class);
        util.exportExcel(response, list, "优惠卷场次关系数据");
    }

    /**
     * 获取优惠卷场次关系详细信息
     */
//    @RequiresPermissions("coupon:CouponSession:query")
    @GetMapping(value = "/{couponSessionId}")
    public Result getInfo(@PathVariable("couponSessionId") Long couponSessionId) {
        return success(couponSessionService.selectCouponSessionByCouponSessionId(couponSessionId));
    }

    /**
     * 新增优惠卷场次关系
     */
//    @RequiresPermissions("coupon:CouponSession:add")
//    @Log(title = "优惠卷场次关系", businessType = BusinessType.INSERT)
    @PostMapping
    public Result add(@RequestBody CouponSession couponSession) {
        return toAjax(couponSessionService.insertCouponSession(couponSession));
    }

    /**
     * 修改优惠卷场次关系
     */
//    @RequiresPermissions("coupon:CouponSession:edit")
//    @Log(title = "优惠卷场次关系", businessType = BusinessType.UPDATE)
    @PutMapping
    public Result edit(@RequestBody CouponSession couponSession) {
        return toAjax(couponSessionService.updateCouponSession(couponSession));
    }

    /**
     * 删除优惠卷场次关系
     */
//    @RequiresPermissions("coupon:CouponSession:remove")
//    @Log(title = "优惠卷场次关系", businessType = BusinessType.DELETE)
    @DeleteMapping("/{couponSessionIds}")
    public Result remove(@PathVariable Long[] couponSessionIds) {
        return toAjax(couponSessionService.deleteCouponSessionByCouponSessionIds(couponSessionIds));
    }


    /**
     * 查询场次
     * @param couponSession
     * @return
     */
    @PostMapping("/findCouponSession")
    public Result<List<CouponSession>> findCouponSession(@RequestBody CouponSession couponSession) {
        List<CouponSession> couponSessionList = couponSessionService.findCouponSession(couponSession);
        return Result.success(couponSessionList);
    }





}
